//
//  SZRecommendMainCell.m
//  KaiJing
//
//  Created by lanou on 16/1/20.
//  Copyright © 2016年 HuangZuCui. All rights reserved.
//

#import "SZRecommendMainCell.h"
#import <UIImageView+WebCache.h>

@implementation SZRecommendMainCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle: style reuseIdentifier:reuseIdentifier];
    if (self) {
        _photoView = [[UIImageView alloc] init];
        _titleLabel = [[UILabel alloc] init];
        _titleLabel.numberOfLines = 0;
        [self.contentView addSubview:_photoView];
        [self.contentView addSubview:_titleLabel];
    }
    return self;
}
- (void)setModel:(SZRecommendModel *)model {
    _model = model;
    if (model.images.length == 0) {
        _photoView.image = nil;
        _titleLabel.frame = CGRectMake(10, 10, kScreenWidth - 20, (kScreenWidth - 30) / 3 - 20);
        _titleLabel.text = model.title;
    } else {
        _titleLabel.frame = CGRectMake(10, 10, (kScreenWidth - 30) * 2 / 3, (kScreenWidth - 30) / 3);
        _titleLabel.text = model.title;
        _photoView.frame = CGRectMake((kScreenWidth - 30) * 2 / 3 + 20, 10, (kScreenWidth - 30) / 3, (kScreenWidth - 30) / 3 - 20);
        [_photoView sd_setImageWithURL:[NSURL URLWithString:model.images] placeholderImage:[UIImage imageNamed:@"recommend_selected"]];
    }
}
@end
